home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / sviluppo / python-1.4 / lib / test / test_strop.py < prev    next >
Text File  |  1996-12-16  |  481b  |  22 lines

  1. import strop, sys
  2.  
  3. def test(name, input, output):
  4.     f = getattr(strop, name)
  5.     try:
  6.     value = f(input)
  7.     except:
  8.      value = sys.exc_type
  9.     if value != output:
  10.     print f, `input`, `output`, `value`
  11.  
  12. test('atoi', " 1 ", 1)
  13. test('atoi', " 1x", ValueError)
  14. test('atoi', " x1 ", ValueError)
  15. test('atol', "  1  ", 1L)
  16. test('atol', "  1x ", ValueError)
  17. test('atol', "  x1 ", ValueError)
  18. test('atof', "  1  ", 1.0)
  19. test('atof', "  1x ", ValueError)
  20. test('atof', "  x1 ", ValueError)
  21.  
  22.